package fr.generali.accueilclient.gwt.client.dispatch;

import java.util.HashMap;

import net.customware.gwt.dispatch.shared.Action;
import net.customware.gwt.dispatch.shared.Result;

public class DefaultActionCache implements ActionCache {

	private static HashMap<Action<Result>, Result> cache = new HashMap<Action<Result>, Result>();
	
	@Override
	public void clear() {
		cache.clear();
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public <A extends Action<R>, R extends Result> void clear(A action) {
		cache.put((Action<Result>) action, null);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public <A extends Action<R>, R extends Result> R get(A action){
		return (R)cache.get(action);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public <A extends Action<R>, R extends Result> void put(A action, R result){
		cache.put((Action<Result>) action, result);
	}

}
